﻿using System.Diagnostics.Contracts;
using System;
using System.Reflection;
using System.Collections.Generic;

namespace CodePlex.Diagnostics.Contracts.Conditions
{
  public static partial class Condition
  {
    [Pure]
    public static bool IsNull(this object value)
    {
      Contract.Ensures(Contract.Result<bool>() == (value == null));

      return value == null;
    }

    [Pure]
    public static bool IsDefault<T>(this T value)
    {
      return Equals(value, default(T));
    }

    [Pure]
    public static bool IsValid(this object value)
    {
      Contract.Requires(!value.IsNull());

      return ContractValidationAttribute.IsValid(value, true, false);
    }

    [Pure]
    public static bool IsValid(this object value, bool inherit, bool recursive)
    {
      Contract.Requires(!value.IsNull());

      return ContractValidationAttribute.IsValid(value, inherit, recursive);
    }
  }
}
